function myExtract(aim, getKey, getValue) {
    const t = {}
    for (const aimKey in aim) {
        const key = getKey(aimKey)
        t[key] = getValue(aimKey)
    }
    return t
}


export const productType = {
    1: {str: "train"},
    2: {str: "flight"},
    20: {str: "hotel"},
    21: {str: "scenic"}
}

export const productTypeCode = (
    myExtract(productType, (key) => productType[key].str, (key) => key)
)
export const productTypeStr = (
    myExtract(productType, (key) => key, (key) => productType[key].str)
)


export const sellState = {
    0: {str: '下架中', tagType: "warning"},
    1: {str: '上架中', tagType: "success"},
}
export const sellStateStr = (
    myExtract(sellState, (key) => key, (key) => sellState[key].str)
)
export const sellStateTagType = (
    myExtract(sellState, (key) => key, (key) => sellState[key].tagType)
)

export const editState = {
    0: {str: "无修改", tagType: "success"},
    1: {str: "修改待审核", tagType: "warning"},
}
export const editStateStr = (
    myExtract(editState, (key) => key, (key) => editState[key].str)
)
export const editStateTagType = (
    myExtract(editState, (key) => key, (key) => editState[key].tagType)
)

export const adminState = {
    "-1": {str: "已删除", tagType: ""},
    0: {str: "新增项", tagType: "info"},
    1: {str: "已确认", tagType: "success"},
    2: {str: "建议修改", tagType: ""},
    3: {str: "必须修改", tagType: "danger"},
}
export const adminStateStr = (
    myExtract(adminState, (key) => key, (key) => adminState[key].str)
)
export const adminStateTagType = (
    myExtract(adminState, (key) => key, (key) => adminState[key].tagType)
)
export const initObj = {}
export const initArray= []
export const localKeys = {
    admin:{token:'adminToken',casId:'adminCasId'},
    supplier:{token:'supplierToken',casId:'supplierCasId'},
    consumer:{token:'consumerToken',casId:'consumerCasId'},
}

export const orderState={
    0: {str: "已下单", tagType: ""},
    1: {str: "消费中", tagType: "success"},
    2: {str: "消费完成", tagType: "success"},
    3: {str: "手动关闭", tagType: "info"},
    4: {str: "商家关闭", tagType: "warning"}
}
export const orderStateStr = (
    myExtract(orderState, (key) => key, (key) => orderState[key].str)
)
export const orderStateTagType = (
    myExtract(orderState, (key) => key, (key) => orderState[key].tagType)
)

